assert(PandaDKP, "PandaDKP not found!")

------------------------------
--      Are you local?      --
------------------------------
local PandaDKP = PandaDKP
local Config =
{
}
PandaDKP.Config = Config


function Config:Enable()
end

function Config:SetPanel(panel, name, parent)
   panel.name = name
   if (nil ~= parent) then panel.parent = parent end
   InterfaceOptions_AddCategory(panel)
end


function Config:ConfigPanelOnShow()
   PDKPM_ConfigLootScanningCheck:SetChecked(PandaDKP.db.realm.LootScanning)
   UIDropDownMenu_Initialize(PDKPM_ConfigThresholdMenu, function() PandaDKP.Config:InitThresholdDropdown() end)
end

function Config:ConfigPanelOnHide()
end



function Config:InitThresholdDropdown()
   local info = UIDropDownMenu_CreateInfo()
   info.owner = PDKPM_ConfigThresholdMenu
   info.func = function() PandaDKP.Config:ThresholdClicked(this) end
   info.checked = nil
   
   local SetText = function(info, text, i)
      info.text = string.format("|cff%s%s|r", PandaDKP:rgbToHex(ITEM_QUALITY_COLORS[i]), text)
      info.value = i
      UIDropDownMenu_AddButton(info, 1)
   end
   
   SetText(info, "Poor", 0)
   SetText(info, "Common", 1)
   SetText(info, "Uncommon", 2)
   SetText(info, "Rare", 3)
   SetText(info, "Epic", 4)
   SetText(info, "Legendary", 5)
   SetText(info, "Artifact", 6)
   
   UIDropDownMenu_SetSelectedValue(PDKPM_ConfigThresholdMenu, PandaDKP.db.realm.ItemQuality)
end

function Config:ThresholdClicked(info)
   PandaDKP.db.realm.ItemQuality = info.value
   UIDropDownMenu_SetSelectedValue(PDKPM_ConfigThresholdMenu, PandaDKP.db.realm.ItemQuality)
end





function Config:LootScanningClicked()
   if (1 == PDKPM_ConfigLootScanningCheck:GetChecked()) then
      PandaDKP:Print("Turning on")
      PandaDKP.db.realm.LootScanning = true
      PandaDKP.Looting:TurnOnLootChecking()
   else
      PandaDKP:Print("Turning off")
      PandaDKP.db.realm.LootScanning = false
      PandaDKP.Looting:TurnOffLootChecking()
   end
end